<?
include_once("../../database.php");
include_once("../../backend.php");
include_once("../../login_management.php");
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/scoutingevent.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<link rel="stylesheet" type="text/css" href="../../scouting.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Create Event | Team Spyder Scouting</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
<div class="main">
<div class="top"><l>
<a class="navigation" href="./index.php">Home</a> | 
<a class="navigation" href="./event.php">Event Management</a> | 
<a class="navigation" href="../index.php"> Admin </a> | 
<script type="text/javascript">
function LoadLogin()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","login.php",true);
xmlhttp.send();
}
</script>

<?
if($logged_in)
{
	echo "<l> Welcome, " . $_SESSION['username'] . " </l>";
	echo "<a class=\"navigation\" href=\"./logout.php\">Log out</a>\n";
}
else
{
	echo "<l> You are not logged in. </l>";
	echo "<a class=\"navigation\" href=\"#\" onclick=\"LoadLogin()\">Log in</a>\n";
}

?>
</l>
</div>
<div class="content"><!-- InstanceBeginEditable name="Content" -->
<?
if($logged_in)
{
?>
<form action="backend.php" method="post" >
<h1 style="text-align:center;">Season Creation</h1>
<p>Note: these fields are the ones that will change year to year.  team and match are already set up.</p>
<table border="2">
<tr>
<td>Field Name</td>
<td>Field Width</td>
<td>Field Max Length</td>
<td>Field Datatype</td>
<td>Chart Page</td>
<td>View Team</td>
<td>View Match</td>
<td>SpyderRank</td>
<td>SpyderRank Total</td>
<?
$numcols=$_GET['fieldnum'];
for($i=1;$i<=$numcols;$i++)
{
	?>
    <tr>
    <td><input type="text" name="field_<? echo $i; ?>_name" /></td>
    <td><input type="text" name="field_<? echo $i; ?>_width" value="<?php echo round((1024/($numcols+2))-($numcols*3),0);  ?>" /></td>
    <td><input type="text" name="field_<? echo $i; ?>_maxval" value="500" /></td>
    <td>
    <select name="field_<? echo $i; ?>_datatype" >
    <option value="varchar" selected="selected">Datatype</option>
    <option value="varchar">VARCHAR(default)</option>
    <option value="int">INT</option>
    <option value="text">TEXT</option>
    <option value="date">DATE</option>
    </select>
    </td>
    <td>
    <input type="checkbox" name="field_<? echo $i; ?>_charts" value="1" />
    </td>
    <td>
    <input type="checkbox" name="field_<? echo $i; ?>_team" value="1" />
    </td>
    <td>
    <input type="checkbox" name="field_<? echo $i; ?>_match" value="1" />
    </td>
    <td>
    <input type="checkbox" name="field_<? echo $i; ?>_predict" value="1" />
    </td>
	<td>
    <input type="checkbox" name="field_<? echo $i; ?>_display" value="1" />
    </td>
    </tr>
    <?
}
?>

</table><br />
<table>
<tr>
<td>Event List</td>
</tr>
<?

$numevents=$_GET['numevents'];
for($i=1;$i<=$numevents;$i++)
{
	?>
    <tr>
    <td><input type="text" name="event_<? echo $i; ?>_name" /></td>
    </tr><?
}

?>
</table><br />
Season Name: <br />
<input type="text" name="compname" /><br />
Year: <br />
<input type="text" name="compyear" /><br />
Competition type: <br />
<select name="comptype">
<option value="FRC">FRC</option>
<option value="VEX">VEX</option>
</select>
<input type="hidden" name="numcols" value="<? echo $numcols; ?>" />
<input type="hidden" name="numevents" value="<? echo $numevents; ?>" />
<input type="hidden" name="createseason" value="1" />
<input type="submit" name="Create Competition" value="Create Competition" />
</form>
<?
}
else
{
	displayLogin();
}
mysql_close();
?>
<!-- InstanceEndEditable -->
</div>
</div>

</body>
<!-- InstanceEnd --></html>
